package com.zhouxiaoge.antlr4.csv;// Generated from .\CSV.g4 by ANTLR 4.10.1

import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.atn.ATN;
import org.antlr.v4.runtime.atn.ATNDeserializer;
import org.antlr.v4.runtime.atn.ParserATNSimulator;
import org.antlr.v4.runtime.atn.PredictionContextCache;
import org.antlr.v4.runtime.dfa.DFA;
import org.antlr.v4.runtime.tree.ParseTreeListener;
import org.antlr.v4.runtime.tree.TerminalNode;

import java.util.List;

@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class CSVParser extends Parser {
    static {
        RuntimeMetaData.checkVersion("4.10.1", RuntimeMetaData.VERSION);
    }

    protected static final DFA[] _decisionToDFA;
    protected static final PredictionContextCache _sharedContextCache =
            new PredictionContextCache();
    public static final int
            T__0 = 1, T__1 = 2, T__2 = 3, TEXT = 4, STRING = 5;
    public static final int
            RULE_file = 0, RULE_hdr = 1, RULE_row = 2, RULE_field = 3;

    private static String[] makeRuleNames() {
        return new String[]{
                "file", "hdr", "row", "field"
        };
    }

    public static final String[] ruleNames = makeRuleNames();

    private static String[] makeLiteralNames() {
        return new String[]{
                null, "','", "'\\r'", "'\\n'"
        };
    }

    private static final String[] _LITERAL_NAMES = makeLiteralNames();

    private static String[] makeSymbolicNames() {
        return new String[]{
                null, null, null, null, "TEXT", "STRING"
        };
    }

    private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
    public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);

    /**
     * @deprecated Use {@link #VOCABULARY} instead.
     */
    @Deprecated
    public static final String[] tokenNames;

    static {
        tokenNames = new String[_SYMBOLIC_NAMES.length];
        for (int i = 0; i < tokenNames.length; i++) {
            tokenNames[i] = VOCABULARY.getLiteralName(i);
            if (tokenNames[i] == null) {
                tokenNames[i] = VOCABULARY.getSymbolicName(i);
            }

            if (tokenNames[i] == null) {
                tokenNames[i] = "<INVALID>";
            }
        }
    }

    @Override
    @Deprecated
    public String[] getTokenNames() {
        return tokenNames;
    }

    @Override

    public Vocabulary getVocabulary() {
        return VOCABULARY;
    }

    @Override
    public String getGrammarFileName() {
        return "CSV.g4";
    }

    @Override
    public String[] getRuleNames() {
        return ruleNames;
    }

    @Override
    public String getSerializedATN() {
        return _serializedATN;
    }

    @Override
    public ATN getATN() {
        return _ATN;
    }

    public CSVParser(TokenStream input) {
        super(input);
        _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache);
    }

    public static class FileContext extends ParserRuleContext {
        public HdrContext hdr() {
            return getRuleContext(HdrContext.class, 0);
        }

        public List<RowContext> row() {
            return getRuleContexts(RowContext.class);
        }

        public RowContext row(int i) {
            return getRuleContext(RowContext.class, i);
        }

        public FileContext(ParserRuleContext parent, int invokingState) {
            super(parent, invokingState);
        }

        @Override
        public int getRuleIndex() {
            return RULE_file;
        }

        @Override
        public void enterRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).enterFile(this);
        }

        @Override
        public void exitRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).exitFile(this);
        }
    }

    public final FileContext file() throws RecognitionException {
        FileContext _localctx = new FileContext(_ctx, getState());
        enterRule(_localctx, 0, RULE_file);
        int _la;
        try {
            enterOuterAlt(_localctx, 1);
            {
                setState(8);
                hdr();
                setState(10);
                _errHandler.sync(this);
                _la = _input.LA(1);
                do {
                    {
                        {
                            setState(9);
                            row();
                        }
                    }
                    setState(12);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                } while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__0) | (1L << T__1) | (1L << T__2) | (1L << TEXT) | (1L << STRING))) != 0));
            }
        } catch (RecognitionException re) {
            _localctx.exception = re;
            _errHandler.reportError(this, re);
            _errHandler.recover(this, re);
        } finally {
            exitRule();
        }
        return _localctx;
    }

    public static class HdrContext extends ParserRuleContext {
        public RowContext row() {
            return getRuleContext(RowContext.class, 0);
        }

        public HdrContext(ParserRuleContext parent, int invokingState) {
            super(parent, invokingState);
        }

        @Override
        public int getRuleIndex() {
            return RULE_hdr;
        }

        @Override
        public void enterRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).enterHdr(this);
        }

        @Override
        public void exitRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).exitHdr(this);
        }
    }

    public final HdrContext hdr() throws RecognitionException {
        HdrContext _localctx = new HdrContext(_ctx, getState());
        enterRule(_localctx, 2, RULE_hdr);
        try {
            enterOuterAlt(_localctx, 1);
            {
                setState(14);
                row();
            }
        } catch (RecognitionException re) {
            _localctx.exception = re;
            _errHandler.reportError(this, re);
            _errHandler.recover(this, re);
        } finally {
            exitRule();
        }
        return _localctx;
    }

    public static class RowContext extends ParserRuleContext {
        public List<FieldContext> field() {
            return getRuleContexts(FieldContext.class);
        }

        public FieldContext field(int i) {
            return getRuleContext(FieldContext.class, i);
        }

        public RowContext(ParserRuleContext parent, int invokingState) {
            super(parent, invokingState);
        }

        @Override
        public int getRuleIndex() {
            return RULE_row;
        }

        @Override
        public void enterRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).enterRow(this);
        }

        @Override
        public void exitRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).exitRow(this);
        }
    }

    public final RowContext row() throws RecognitionException {
        RowContext _localctx = new RowContext(_ctx, getState());
        enterRule(_localctx, 4, RULE_row);
        int _la;
        try {
            enterOuterAlt(_localctx, 1);
            {
                setState(16);
                field();
                setState(21);
                _errHandler.sync(this);
                _la = _input.LA(1);
                while (_la == T__0) {
                    {
                        {
                            setState(17);
                            match(T__0);
                            setState(18);
                            field();
                        }
                    }
                    setState(23);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                }
                setState(25);
                _errHandler.sync(this);
                _la = _input.LA(1);
                if (_la == T__1) {
                    {
                        setState(24);
                        match(T__1);
                    }
                }

                setState(27);
                match(T__2);
            }
        } catch (RecognitionException re) {
            _localctx.exception = re;
            _errHandler.reportError(this, re);
            _errHandler.recover(this, re);
        } finally {
            exitRule();
        }
        return _localctx;
    }

    public static class FieldContext extends ParserRuleContext {
        public FieldContext(ParserRuleContext parent, int invokingState) {
            super(parent, invokingState);
        }

        @Override
        public int getRuleIndex() {
            return RULE_field;
        }

        public FieldContext() {
        }

        public void copyFrom(FieldContext ctx) {
            super.copyFrom(ctx);
        }
    }

    public static class StringContext extends FieldContext {
        public TerminalNode STRING() {
            return getToken(CSVParser.STRING, 0);
        }

        public StringContext(FieldContext ctx) {
            copyFrom(ctx);
        }

        @Override
        public void enterRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).enterString(this);
        }

        @Override
        public void exitRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).exitString(this);
        }
    }

    public static class TextContext extends FieldContext {
        public TerminalNode TEXT() {
            return getToken(CSVParser.TEXT, 0);
        }

        public TextContext(FieldContext ctx) {
            copyFrom(ctx);
        }

        @Override
        public void enterRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).enterText(this);
        }

        @Override
        public void exitRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).exitText(this);
        }
    }

    public static class EmptyContext extends FieldContext {
        public EmptyContext(FieldContext ctx) {
            copyFrom(ctx);
        }

        @Override
        public void enterRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).enterEmpty(this);
        }

        @Override
        public void exitRule(ParseTreeListener listener) {
            if (listener instanceof CSVListener) ((CSVListener) listener).exitEmpty(this);
        }
    }

    public final FieldContext field() throws RecognitionException {
        FieldContext _localctx = new FieldContext(_ctx, getState());
        enterRule(_localctx, 6, RULE_field);
        try {
            setState(32);
            _errHandler.sync(this);
            switch (_input.LA(1)) {
                case TEXT:
                    _localctx = new TextContext(_localctx);
                    enterOuterAlt(_localctx, 1);
                {
                    setState(29);
                    match(TEXT);
                }
                break;
                case STRING:
                    _localctx = new StringContext(_localctx);
                    enterOuterAlt(_localctx, 2);
                {
                    setState(30);
                    match(STRING);
                }
                break;
                case T__0:
                case T__1:
                case T__2:
                    _localctx = new EmptyContext(_localctx);
                    enterOuterAlt(_localctx, 3);
                {
                }
                break;
                default:
                    throw new NoViableAltException(this);
            }
        } catch (RecognitionException re) {
            _localctx.exception = re;
            _errHandler.reportError(this, re);
            _errHandler.recover(this, re);
        } finally {
            exitRule();
        }
        return _localctx;
    }

    public static final String _serializedATN =
            "\u0004\u0001\u0005#\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002" +
                    "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0001\u0000\u0001\u0000\u0004" +
                    "\u0000\u000b\b\u0000\u000b\u0000\f\u0000\f\u0001\u0001\u0001\u0001\u0001" +
                    "\u0002\u0001\u0002\u0001\u0002\u0005\u0002\u0014\b\u0002\n\u0002\f\u0002" +
                    "\u0017\t\u0002\u0001\u0002\u0003\u0002\u001a\b\u0002\u0001\u0002\u0001" +
                    "\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0003\u0003!\b\u0003\u0001" +
                    "\u0003\u0000\u0000\u0004\u0000\u0002\u0004\u0006\u0000\u0000#\u0000\b" +
                    "\u0001\u0000\u0000\u0000\u0002\u000e\u0001\u0000\u0000\u0000\u0004\u0010" +
                    "\u0001\u0000\u0000\u0000\u0006 \u0001\u0000\u0000\u0000\b\n\u0003\u0002" +
                    "\u0001\u0000\t\u000b\u0003\u0004\u0002\u0000\n\t\u0001\u0000\u0000\u0000" +
                    "\u000b\f\u0001\u0000\u0000\u0000\f\n\u0001\u0000\u0000\u0000\f\r\u0001" +
                    "\u0000\u0000\u0000\r\u0001\u0001\u0000\u0000\u0000\u000e\u000f\u0003\u0004" +
                    "\u0002\u0000\u000f\u0003\u0001\u0000\u0000\u0000\u0010\u0015\u0003\u0006" +
                    "\u0003\u0000\u0011\u0012\u0005\u0001\u0000\u0000\u0012\u0014\u0003\u0006" +
                    "\u0003\u0000\u0013\u0011\u0001\u0000\u0000\u0000\u0014\u0017\u0001\u0000" +
                    "\u0000\u0000\u0015\u0013\u0001\u0000\u0000\u0000\u0015\u0016\u0001\u0000" +
                    "\u0000\u0000\u0016\u0019\u0001\u0000\u0000\u0000\u0017\u0015\u0001\u0000" +
                    "\u0000\u0000\u0018\u001a\u0005\u0002\u0000\u0000\u0019\u0018\u0001\u0000" +
                    "\u0000\u0000\u0019\u001a\u0001\u0000\u0000\u0000\u001a\u001b\u0001\u0000" +
                    "\u0000\u0000\u001b\u001c\u0005\u0003\u0000\u0000\u001c\u0005\u0001\u0000" +
                    "\u0000\u0000\u001d!\u0005\u0004\u0000\u0000\u001e!\u0005\u0005\u0000\u0000" +
                    "\u001f!\u0001\u0000\u0000\u0000 \u001d\u0001\u0000\u0000\u0000 \u001e" +
                    "\u0001\u0000\u0000\u0000 \u001f\u0001\u0000\u0000\u0000!\u0007\u0001\u0000" +
                    "\u0000\u0000\u0004\f\u0015\u0019 ";
    public static final ATN _ATN =
            new ATNDeserializer().deserialize(_serializedATN.toCharArray());

    static {
        _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
        for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
            _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
        }
    }
}